/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 殇
 * Date: 2025-05-20
 * Time: 11:48
 */
//两数之和
public class code5 {
    public static int[] twoSum(int[] nums,int target){
        int n=nums.length;
        int[] ret=new int[2];
        int flag=1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(flag==0)
                    break;
                if(nums[i]+nums[j]==target){
                    ret[0]=i;
                    ret[1]=j;
                    flag=0;
                }
            }
        }
        return ret;
    }
    public static void main(String[] args) {
        int[] nums1=new int[]{2,7,11,5};
        int[] nums2=new int[]{3,2,4};
        int[] tmp1=twoSum(nums1,9);
        int[] tmp2=twoSum(nums2,6);
        for(int x: tmp1){
            System.out.print(x+" ");
        }
        System.out.print('\n');
        for(int x: tmp2){
            System.out.print(x+" ");
        }
    }
}
